﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using TestProject.FunWithExpressions;
using System.Linq.Expressions;
using System.Text.RegularExpressions;

namespace TestProject
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("////// Bienvenu dans l'application de test ! //////////");
            Console.WriteLine();


            //TestMail.SendMailTest();
            //Console.WriteLine(1.ToString("00"));
            //Console.WriteLine(new ArgumentException("truc {0} esxiste pas", "patate"));
            //TestProject.FunWithExpressions.ExpressionTester.ExpressionTest();

            //decimal d = 37.25m;

            //Console.WriteLine(d.ToString());
            //Console.WriteLine(d.ToString("#"));
            //Console.WriteLine(d.ToString("#.0"));
            //Console.WriteLine(d.ToString("#.00"));
            //Console.WriteLine(d.ToString("#.0'0'"));
            //Console.WriteLine(d.ToString("#"));

            TestProject.FunWithAD.TestAD.Test();

            //var r = HttpWebRequest.Create("http://localhost:3253/Pilotage/Cache/UpdateCache");
            //r.Method = "POST";
            //r.ContentLength = 0;
            //try
            //{
            //    var rs = r.GetResponse();
            //    var mr = new StreamReader(rs.GetResponseStream());
            //    var content = mr.ReadToEnd(); 
            //    Console.WriteLine(content);
            //}
            //catch
            //{
            //    Console.WriteLine("Update Failed");
            //}


            //IEnumerable<DataInfo> patate = new List<DataInfo>
            //{
            //    new DataInfo()
            //    { A = 1, B = 2, C=3},
            //    new DataInfo()
            //    { A = 11, B = 12, C=13}
            //};
            //var typeDataInfo = typeof(DataInfo);
            //var propertyName = "C";
            //var prop = typeDataInfo.GetProperty(propertyName);
            //var paramExp = Expression.Parameter(typeDataInfo, "x");
            //var sortExp = Expression.Lambda<Func<DataInfo,typeof(prop) >(Expression.Add(paramExp, Expression.PropertyOrField(paramExp, propertyName)));
            

            //patate.OrderBy(sortExp);

            var regex = @"^(LDAP|LDAPS)://((?:(?:(?:\w+)\.)*)(?:\w+))/((?:(?:(?:OU|DC)=(?:\w+),)+)(?:OU|DC)=(?:\w+))$";
            var str = "LDAP://sl20120120.tourisme.gouv.qc.ca/OU=Tourisme,DC=dev,DC=tourisme,DC=gouv,DC=qc,DC=ca";
            var match = Regex.Match(str,regex);
            Console.WriteLine(match.Success);
            Console.WriteLine(match.Groups.Count);
            foreach (Group group in match.Groups)
            {
                Console.WriteLine("{0} : {1}", group.Index, group.Value);
            }
            
            
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("------------------------");
            Console.WriteLine("Maman c'Est fini !");
            Console.WriteLine("Appuyer sur une touche pour terminer");

            Console.ReadLine();

        }
    }
}
